package band.wukong.practice.webservice.kh.sample02.nongen;

import band.wukong.practice.webservice.kh.sample02.SomebodyService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.Assert;
import org.testng.annotations.BeforeClass;
import org.testng.annotations.Test;

import javax.xml.namespace.QName;
import javax.xml.ws.Service;
import java.net.URL;

/**
 * As you see...
 *
 * @author wukong(wukonggg@139.com)
 */
public class SomebodyClientByServerAPI {

    private static final Logger logger = LoggerFactory.getLogger(SomebodyClientByServerAPI.class);

    private SomebodyService port;

    @BeforeClass
    public void init() throws Exception {
        URL url = new URL(SomebodyConst.SERVICE_URL);
//        URL url = new URL(SomebodyConst.SERVICE_URL_DEBUG);   // TCPMon
        QName qname = new QName(SomebodyConst.SERVICE_NS, SomebodyConst.SERVICE_NAME);
        Service service = Service.create(url, qname);
        port = service.getPort(SomebodyService.class);
    }

    @Test
    public void sing() {
        final String words = "Master! Master! ";
        String ret = port.sing(words);
        logger.info(ret);

        Assert.assertEquals(ret, words);
    }

    @Test
    public void bandInfo() {

        String ret = port.bandInfo("Metallica", "TrashMetal").toString();
        logger.info(ret);

        Assert.assertNotNull(ret);

    }

    @Test
    public void now() {
        String ret = port.now().toString();
        logger.info(ret);

        Assert.assertNotNull(ret);

    }

}
